package com.syh.service.impl;

import com.syh.mapper.PeopleMapper;
import com.syh.pojo.People;
import com.syh.pojo.PeopleExample;
import com.syh.service.PeopleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author syh
 * @date 2023/3/30-19:43
 */
@Service
@SuppressWarnings("all")
public class PeopleServiceImpl implements PeopleService {
    @Autowired
    PeopleMapper peopleMapper;

    @Override
    public List<People> selectAll() {
        PeopleExample peopleExample=new PeopleExample();
        return peopleMapper.selectByExample(peopleExample);
    }

    @Override
    public void insertpeople(People shop) {

            peopleMapper.insert(shop);
    }

    @Override
    public void updatepeople(People shop) {
    peopleMapper.updateByPrimaryKey(shop);
    }

    @Override
    public void deletepeople(People shop) {
    peopleMapper.deleteByPrimaryKey(shop.getId());
    }

    @Override
    public People selectpeople(String name) {
        PeopleExample peopleExample=new PeopleExample();
        peopleExample.createCriteria().andNameEqualTo(name);
        List<People> people = peopleMapper.selectByExample(peopleExample);
        return people.get(0);
    }
}
